import time

from page_object.cat_duima import Public_Catdm
from page_object.data_query import DataQuery
from page_object.form_write import FormWrite
from page_object.fx_flow_manage import Test_Fx_flow
from page_object.polycentric_duiliecat import PolycenticDuiliecat
from page_object.queue_data_house import QueueData
from page_object.suanfa_manage import SuanfaManage
from page_object.zhibiaoku import ZhibiaokuCat

from tools.base_page import BasePage


class MainPage(BasePage):
    base_host = 'http://172.16.10.21'
    _base_url = base_host+'/sso/login/#/'  # 登录入口



    def select_role(self):
        time.sleep(2)
        role_locator = self.only_read_yaml('../data/index.yaml', 'role')
        self.verify_wait_click(role_locator)
        self.selector_execute_script(role_locator[1])


    def goto_role(self):
        #role_locator = self.only_read_yaml('../data/index.yaml','role')
        # time.sleep(2)
        # self.verify_wait_click(self.role_locator)
        # self.find(self.role_locator).click()
        #self.selector_execute_script(role_locator[1])
        self.select_role()
        return DataQuery(self.driver)


    def goto_role_queue_data(self):
        # role_locator = self.only_read_yaml('../data/index.yaml','role')[1]
        # time.sleep(2)
        # self.verify_wait_click(self.role_locator)
        # self.find(self.role_locator).click()
        self.select_role()
        return QueueData(self.driver)

    def goto_zhibiaoku_cat(self):
        #role_locator = self.only_read_yaml('../data/index.yaml','role')[1]
        # time.sleep(2)
        # self.verify_wait_click(self.role_locator)
        # self.find(self.role_locator).click()
        # time.sleep(2)
        self.select_role()
        time.sleep(2)
        self.driver.get(self.base_host+'/mrpv2/#/variableBaseManageByDeptMember')
        time.sleep(2)
        return ZhibiaokuCat(self.driver)

    def goto_suanfa_manage(self):
        self.select_role()
        time.sleep(2)
        self.driver.get(self.base_host+'/mrpv2/#/selfCreatedAlgorithmByDeptMember')
        time.sleep(2)
        return SuanfaManage(self.driver)


    def goto_fx_flow_manage(self):
        self.select_role()
        time.sleep(2)
        self.driver.get(self.base_host+'/mrpv2/#/analysisProcess')
        time.sleep(2)
        return Test_Fx_flow(self.driver)



    def goto_polycentric_dl_cat(self): # 多中心结果查询
        self.select_role()
        time.sleep(2)
        self.driver.get(self.base_host+'/mrpv2/#/MulticenterDatabasePreviewByDeptMember')
        time.sleep(2)
        return PolycenticDuiliecat(self.driver)


    # def goto_analysis_res_query(self):  #  分析结果查询
    #     self.select_role()
    #     time.sleep(2)
    #     self.driver.get(self.base_host+'/mrpv2/#/analysisToolsResultsByDeptMember')
    #     time.sleep(2)
    #     return


    def goto_form_write(self):
        self.select_role()
        time.sleep(2)
        self.driver.get(self.base_host+'/mrpv2/#/formEntry')
        time.sleep(2)
        return FormWrite(self.driver)

    def goto_cat_duima(self): # 公共对码数据查看
        self.select_role()
        time.sleep(2)
        self.driver.get(self.base_host+'/mrpv2/#/publicViewOfCodeData')
        time.sleep(2)
        return Public_Catdm(self.driver)



